/**
 * File: date.c
 * Author : Lom
 * Implementation de date.h
 */

#include <time.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "date.h"
#include "typesprimitifs.h"


POINTEUR_DATE creer_date()
{
   /* Premiere chose a faire : recuperer la date */
   time_t timestamp = time(NULL);
   POINTEUR_DATE pd = malloc(sizeof(*pd));
   CHAINE buffer;

   /*Formater ensuite la date sous un format specifique*/
   strftime(buffer, sizeof(buffer), "%A %d %B %Y - %X.", localtime(&timestamp));

   /*Creer la bonne structure et la renvoyer*/
   pd->date_courante = timestamp;
   strcpy(pd->representation, buffer);

   return pd;
}

void afficher_date(POINTEUR_DATE pd)
{
    printf("%s\n", pd->representation);
}

void liberer_date(POINTEUR_DATE pd)
{
    free(pd);
}

